﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Longbow.Data;
using Gammar.Price.ObjectModel;

namespace Gammar.Price.DataAccess
{
    /// <summary>
    /// 
    /// </summary>
    public partial class Sp_RecommandItem : ReaderCommand<Sp_RecommandItemEntity>
    {
        private Guid? _ocid;
        
        /// <summary>
        /// 
        /// </summary>            
        public Sp_RecommandItem(Guid? ocid)
        {
            _ocid = ocid;
        }
        
        /// <summary>
        /// 
        /// </summary>            
        protected override CommandType CommandType
        {
            get { return CommandType.StoredProcedure; }
        }

        /// <summary>
        /// 
        /// </summary>            
        protected override string CommandText
        {
            get { return "sp_RecommandItem"; }
        }

        /// <summary>
        /// 
        /// </summary>            
        protected override void AddParameters(DbParameterCollection parameters, DBAccess db)
        {
            parameters.Add(db.CreateParameter("@ocid", DBAccess.ToDBValue(_ocid), ParameterDirection.Input));
        }

        /// <summary>
        /// 
        /// </summary>            
        protected override Sp_RecommandItemEntity ParseRow(DbDataReader reader)
        {
            Sp_RecommandItemEntity obj = new Sp_RecommandItemEntity();
            obj.Oc_id = (Guid?)DBAccess.ToObjectValue(reader["Oc_id"]);
            obj.Typename = (string)DBAccess.ToObjectValue(reader["Typename"]);
            obj.Title = (string)DBAccess.ToObjectValue(reader["Title"]);
            obj.Promotepricevar = (string)DBAccess.ToObjectValue(reader["Promotepricevar"]);
            obj.Promotepricemon = (decimal?)DBAccess.ToObjectValue(reader["Promotepricemon"]);
            obj.Presideunit = (string)DBAccess.ToObjectValue(reader["Presideunit"]);
            obj.Srcweb = (string)DBAccess.ToObjectValue(reader["Srcweb"]);
            obj.Introduction = (string)DBAccess.ToObjectValue(reader["Introduction"]);
            obj.Recommindex = (int?)DBAccess.ToObjectValue(reader["Recommindex"]);
            obj.Counter = (int?)DBAccess.ToObjectValue(reader["Counter"]);
            obj.Url = (string)DBAccess.ToObjectValue(reader["Url"]);
            obj.Type = (Guid?)DBAccess.ToObjectValue(reader["Type"]);
            return obj;
        }
    }
}